import 'dart:math';

import 'package:flutter/material.dart';
import 'package:hello/service/http_request.dart';

main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: AppBar(
          title: Text("dio"),
          centerTitle: true,
        ),
      ),
      body: Content(),
    );
  }
}

class Content extends StatefulWidget {
  const Content({Key key}) : super(key: key);

  @override
  _ContentState createState() => _ContentState();
}

class _ContentState extends State<Content> {

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    //发送网络请求
    HttpRequest.request("https://httpbin.org/get").then((value) => {
      print(value)
    });
    HttpRequest.request("https://httpbin.org/post",method: "POST").then((value) => {
      print(value)
    });
  }

  @override
  Widget build(BuildContext context) {
    return Text("你好啊");
  }
}